package com.health.controller;

import com.health.annotation.AdminLog;
import com.health.common.Result;
import com.health.entity.pojo.dto.QueryAppointmentSettingDTO;
import com.health.service.IAppointmentSettingService;
import com.health.service.IConsultingroomService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 * 预约表 前端控制器
 * </p>
 *
 * @author health
 * @since 2023-04-17
 */
@Api(tags = "预约设置管理")
@RestController
@RequestMapping("/appointmentSetting")
public class AppointmentSettingController extends BaseController {

    @Autowired
    IAppointmentSettingService appointmentSettingService;

    @GetMapping("/listAppointSetting")
    @ApiOperation("预约设置列表")
    @AdminLog("预约设置列表")
    public Result listAppointSetting() {
        return dataResult(appointmentSettingService.listAppointSetting());
    }

    @DeleteMapping("/deleteAppointSetting")
    @ApiOperation("删除预约设置")
    @AdminLog("删除预约设置")
    public Result deleteAppointSetting(@RequestBody List<Integer> ids) {
        if (ids.size() > 1)
            return booleanResult(appointmentSettingService.removeBatchByIds(ids));
        if (ids.size() == 1)
            return booleanResult(appointmentSettingService.removeById(ids.get(0)));
        return error();
    }

    @GetMapping("/getAppointSettingById")
    @ApiOperation("根据id获取预约设置信息")
    @AdminLog("根据id获取预约设置信息")
    public Result getAppointSettingById(@RequestParam("id") Integer id) {
        return dataResult(appointmentSettingService.getById(id));
    }

    @PostMapping("/addOrUpdateAppoint")
    @ApiOperation("添加或者更新预约信息")
    @AdminLog("添加或者更新预约信息")
    public Result addOrUpdateAppoint(@RequestBody QueryAppointmentSettingDTO appointmentDTO) {
        return rowResult(appointmentSettingService.addOrUpdateAppoint(appointmentDTO));
    }

}
